import axios from "axios"

const module = {
    namespaced: true,
    state: {
        banners: "",
        dataList: ""
    },
    mutations: {
        setBanners(state, data) {
            state.banners = data
        },

        setDataList(state, data) {
            state.dataList = data
        },
    },
    actions: {
        // banners
        getBanners({ commit }, soliId) {
            axios.get(`http://www.mei.com/appapi/home/mktBannerApp/v3?silo_id=${soliId}&platform_code=PLATEFORM_H5`)
                .then(res => {

                    if(res.data.banners===[]){
                        commit("setBanners",[ { "main_image": "http://cdn13.mei.com/category/20181024/7abbfbe23f8df872223b5226dc14234b071407a2f321be85.jpg"} ]
                        )
                    }else{
                        commit("setBanners", res.data.banners[0])
                    }
                    // console.log(res.data.banners)

                })
        },
        //dataList
        getDataList({ commit }, categoryId) {
            axios.get(`http://www.mei.com/appapi/silo/eventForH5?categoryId=${categoryId}&pageIndex=1&timestamp=1586487841997&summary=dabf43a6b184b61d724b70a45223c013&platform_code=H5`).then(res => {
                commit("setDataList", res.data.eventList)
            })
        },
    },

}
export default module
